//
//  PayMoneyManagerViewController.m
//  PropertyManager
//
//  Created by TNG on 2018/7/17.
//  Copyright © 2018年 Tng. All rights reserved.
//

#import "PayMoneyManagerViewController.h"

@interface PayMoneyManagerViewController () <UITableViewDelegate,UITableViewDataSource>

@property (strong, nonatomic) UITableView * tableview;
@property (strong, nonatomic) UIView * bgView;

@end

@implementation PayMoneyManagerViewController

static NSString * cellID = @"cell";
static NSString * PayMoenyManagerHeaderTableViewCellID = @"PayMoenyManagerHeaderTableViewCell";
static NSString * PayMoneyManagerContentTableViewCellID = @"PayMoneyManagerContentTableViewCell";

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self creatTableview];
    [self registCell];
    [self wr_setNavBarShadowImageHidden:YES];
    [self wr_setNavBarBarTintColor:SFMNavBarColor];
}

-(UIView *)bgView
{
    if (_bgView == nil) {
        _bgView = [[UIView alloc] initWithFrame:CGRectZero];
        _bgView.backgroundColor = SFMNavBarColor;
    }
    return _bgView;
}

-(void)registCell
{
    [self.tableview registerClass:[UITableViewCell class] forCellReuseIdentifier:cellID];
    [self.tableview registerClass:[PayMoenyManagerHeaderTableViewCell class] forCellReuseIdentifier:PayMoenyManagerHeaderTableViewCellID];
    [self.tableview registerClass:[PayMoneyManagerContentTableViewCell class] forCellReuseIdentifier:PayMoneyManagerContentTableViewCellID];
}

-(void)creatTableview{
    if (self.tableview == nil) {
        UITableView * tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, kStatusAndNavBarH, WIDTH, HEIGHT - kHomeLineH - kStatusAndNavBarH) style:UITableViewStylePlain];
        tableview.delegate = self;
        tableview.dataSource = self;
        tableview.backgroundColor = SFMNavBarColor;
        tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
        if (@available(iOS 11.0, *)) {
            tableview.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic;
        }
        self.tableview = tableview;
        [self.view addSubview:self.tableview];
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        return 131;
    }else
    {
        return 373;
    }
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 2;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        PayMoenyManagerHeaderTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:PayMoenyManagerHeaderTableViewCellID];
        return cell;
    }else
    {
        PayMoneyManagerContentTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:PayMoneyManagerContentTableViewCellID];
        return cell;
    }
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    self.bgView.frame = CGRectMake(0, 0, WIDTH, - scrollView.contentOffset.y);
    self.bgView.backgroundColor = SFMNavBarColor;
}

-(BOOL)hidesBottomBarWhenPushed
{
    return YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
